package cn.torna.example.web.controller.common;

import cn.torna.example.common.Result;
import cn.torna.example.web.controller.product.param.LoginParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * 登录
 * @author tanghc
 */
@RestController
@RequestMapping("login")
public class LoginController {

    /**
     * 登录接口
     * @param param
     * @return
     */
    @PostMapping("login")
    public Result<LoginVO> login(@RequestBody LoginParam param) {
        LoginVO loginVO = new LoginVO();
        loginVO.setUserId(1);
        loginVO.setUsername(param.getUsername());
        loginVO.setToken(UUID.randomUUID().toString());
        return Result.ok(loginVO);
    }


    public static class LoginVO {
        /**
         * 用户id2
         * @mock 112
         */
        private Integer userId;

        /**
         * 用户名2
         * @mock admin2
         */
        private String username;

        /**
         * 登录token2
         * @mock xxxx2
          */
        private String token;

        public Integer getUserId() {
            return userId;
        }

        public void setUserId(Integer userId) {
            this.userId = userId;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        public String getToken() {
            return token;
        }

        public void setToken(String token) {
            this.token = token;
        }
    }


}
